import { Component, Vue } from 'vue-property-decorator'

@Component({
  name: 'IndexMixin'
})
export default class extends Vue {
  initPanigationQuery: any = { pageSize: 10, pageNo: 1 }
  panigationQuery: any = Object.assign({}, this.initPanigationQuery)
  list: any[] = []
  listLoading: boolean = false
  initFilterQuery: any = {}
  filterQuery: any = {}
  listQuery: any = {}
  panigationResult: any = {}

  created() {
    console.log('=-=-=-', this.initFilterQuery)
    this.filterQuery = { ...this.initFilterQuery }
  }

  getList(params: any) {}

  updatePanigationQuery(params: any) {
    this.panigationQuery = Object.assign({}, this.panigationQuery, params)
  }

  updateFilterQuery(params: any) {
    this.filterQuery =
      Object.keys(params).length > 0
        ? Object.assign({}, this.filterQuery, params)
        : this.initFilterQuery
  }

  getQueryParam() {
    return { ...this.panigationQuery, ...this.filterQuery }
  }

  async queryList() {
    console.log('this.getQueryParam()', this.getQueryParam())
    this.listLoading = true
    const data: any = await this.getList(this.getQueryParam())
    this.list = data.records
    this.panigationResult.total = data.total
    this.listLoading = false
  }

  handleSizeChange() {}
  handleCurrentChange() {}
}
